﻿using System.Linq;
using Abp.AspNetCore;
using Abp.Collections.Extensions;
using Abp.Dependency;
using Abp.Domain.Repositories;
using AbpAspNetCoreDemo.Core.Domain;
using AbpAspNetCoreDemoV2.Db;
using Microsoft.AspNetCore.Mvc;

namespace AbpAspNetCoreDemoV2.Controllers
{
    public class HomeController : DemoControllerBase
    {
        private readonly IProductRepository repo;

        public HomeController(IProductRepository repo)
        {
            this.repo = repo;
        }

        public IActionResult Index(string returnUrl = "")
        {
            var islocal = AbpUrlHelper.IsLocalUrl(Request, returnUrl);
           
            return View();
        }

        public IActionResult About([FromServices]IRepository<Product> repository)
        {
            var namStr = repository.GetAll().Select(p => p.Name).JoinAsString(",");
            ViewData["Message"] = L("AboutDescription");

            return View();
        }

        public IActionResult Contact()
        {
            var namStr = repo.GetAll().Select(p => p.Name).JoinAsString(",");
            ViewData["Message"] = "Your contact page." + namStr;

            return View();
        }

        public IActionResult Error()
        {
            return View();
        }
    }
}
